<?php

namespace Product\Entity;

class Product {
    
    protected $id;
    /**
     * @var string
     */
    protected $name;

    /**
     * @var int
     */
    protected $price;

    /**
     * @var Brand
     */
    protected $brand;

    /**
     * @var array
     */
    protected $categories;
    
    public function getId() {
        return $this->id;
    }

    public function setId($id) {
        $this->id = $id;
    }

        /**
     * @param string $name
     * @return Product
     */
    public function setName($name) {
        $this->name = $name;
        return $this;
    }

    /**
     * @return string
     */
    public function getName() {
        return $this->name;
    }

    /**
     * @param int $price
     * @return Product
     */
    public function setPrice($price) {
        $this->price = $price;
        return $this;
    }

    /**
     * @return int
     */
    public function getPrice() {
        return $this->price;
    }

    /**
     * @param Brand $brand
     * @return Product
     */
    public function setBrand(Brand $brand) {
        $this->brand = $brand;
        return $this;
    }

    /**
     * @return Brand
     */
    public function getBrand() {
        return $this->brand;
    }

    /**
     * @param array $categories
     * @return Product
     */
    public function setCategories(array $categories) {
        $this->categories = $categories;
        return $this;
    }

    /**
     * @return array
     */
    public function getCategories() {
        return $this->categories;
    }
    
    
    public function exchageArray($data)
    {
        $this->id = $data['id'] ? $data['id'] : null ;
        $this->name = $data['name'] ? $data['name'] : null;
        $this->price = $data['price'] ? $data['price'] : null;
    }
    
     /**
     * Convert the object to an array.
     *
     * @return array
     */
    public function getArrayCopy() 
    {
        return get_object_vars($this);
    }
    
    public function populate($data = array()) 
    {
        $this->id = $data['id'];
        $this->name = $data['name'];
        $this->price = $data['price'];
	//$this->brand = $data['brand_id'];
	//$this->categories = $data['category_id'];	
    }
 
}
